#include<iostream>
using namespace std;

class Person{
public:
    Person(){
        cout << "Person 构造函数" << endl;
        mAge = 20;
        pName = (char *)malloc(strlen("chenyingchun") + 1);
        strncpy(pName, "chenyingchun", strlen("chenyingchun") + 1);
    }
    void Init(){
        cout << "Init 调用" << endl;
		mAge = 20;
		pName = (char*)malloc(strlen("john")+1);
		strcpy(pName, "john");
	}
    void Clean(){
		if (pName != NULL){
			free(pName);
		}
	}
    ~Person(){
        cout << "析构函数" << endl;
        if (pName != NULL){
			free(pName);
		}
    }
public:
    int mAge;
    char *pName;
};


int main(int argc, char *argv[])
{
#if 0
    Person *person = (Person *)malloc(sizeof(Person));
    if (person == NULL){
        cout << "malloc error " << endl;
        return -1;
    }
    person->Init();

    person->Clean();
    free(person);
#else
    Person *person = new Person;
    delete person;

    // Person *person = new Person[10];
    // delete[] person;
#endif
}
